package cloudspace.vm.javassist;

import java.util.List;

import javassist.CannotCompileException;
import javassist.CtClass;
import javassist.CtMethod;
import javassist.CtNewMethod;
import javassist.NotFoundException;
import javassist.expr.Expr;

public class InsertAfter extends AbstractCommand
{

	protected InsertAfter(List<String> argList)
			throws MalformedCommandException
	{
		super(argList);
	}

	@Override
	public void translate(Expr call, boolean isSuper)
			throws MalformedCommandException, CannotCompileException
	{
		// TODO Auto-generated method stub

	}
	public String getReplacement()
	{
		return unParsedArgs.get(4).substring(1, unParsedArgs.get(4).length() - 1);
	}
	@Override
	public void translate(CtMethod member, String expressionName)
			throws MalformedCommandException, CannotCompileException
	{
		if (expressionName.equals(getSignature()) && ClassAnalyzer.inSuperChain(member.getDeclaringClass(),unParsedArgs.get(3)))
		{
			String replacement = getReplacement();
			member.insertAfter(getReplacement());

		}
	}

}
